package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.dto.ChangePasswordDto;
import com.itheima.dto.EmpQueryDto;
import com.itheima.pojo.Emp;
import com.itheima.vo.EmpItemVo;
import com.itheima.vo.EmpVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 员工管理
 */
@Mapper
public interface EmpMapper {
    //员工列表查询
    Page<EmpVo> query(EmpQueryDto dto);

    //批量删除员工
    //void delete(List<Integer> ids);
    @Delete("delete from emp where id = #{id}")
    void delete(Integer id);

    //添加员工
    void insert(Emp emp);

    //根据ID查询
    @Select("select * from emp where id = #{id}")
    Emp findById(Integer id);

    //修改员工
    void update(Emp emp);

    //查询全部员工
    @Select("select * from emp order by update_time desc")
    List<Emp> findAll();

    //员工性别统计
    @Select("select if(gender=1,'男性员工', '女性员工')name, count(*)value from emp group by gender")
    List<EmpItemVo> getEmpGenderData();
    //员工职位人数统计
    List<EmpItemVo> getEmpJobData();

    //员工登录
    @Select("select * from emp where username = #{username}")
    Emp findByUsername(String username);

    //根据部门ID删除员工
    @Delete("delete from emp where dept_id = #{deptId}")
    void deleteByDeptId(Integer dpetId);

}
